<%@ page pageEncoding="UTF-8"%>

<!-- 插入记录模态框 -->

<div class="modal fade" id="insertModal" tabindex="-1" role="dialog"
	aria-labelledby="exampleModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="exampleModalLabel">插入商品信息框</h4>
			</div>

			<div class="modal-body">
				<form class="form-horizontal" id="insertForm">
					<div class="form-group">
						<label for="name" class="col-sm-2 control-label">商品名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="name" name="name"
								placeholder="name">
						</div>
					</div>
					<div class="form-group">
						<label for="price" class="col-sm-2 control-label">商品价格</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="price" name="price"
								placeholder="price">
						</div>
					</div>
					<div class="form-group">
						<label for="producetime" class="col-sm-2 control-label">生产日期</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="producetime"
								name="producetime" placeholder="producetime">
						</div>
					</div>
					<div class="form-group">
						<label for="madefactory" class="col-sm-2 control-label">生产厂家</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="madefactory"
								name="madefactory" placeholder="madefactory">
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" id="insertRecord">插入</button>
			</div>
		</div>
	</div>
</div>


<script type="text/javascript">
	$("#insertBtn").click(function() {
		//alert("ha");
		$("#insertModal").modal({
			backdrop : 'static'
		});
	});

	var currentPage = 1;

	$("#insertRecord").click(function() {
		$.ajax({
			url : '${path}/insert.action',
			type : 'post',
			data : $("#insertForm").serialize(),
			success : function(result){
				window.location.href='${path}/show.action?pn='+currentPage;
			}
		})
	})
</script>
